package com.hr.config;

import com.hr.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer{
    /*
    * 配置拦截器的步骤:
    *   1.加入 @Configuration  注解
    *   2.实现 WebMvcConfigurer  接口
    *   3.重写addInterceptors方法
    *   4.调用 InterceptorRegistry 的注册拦截器方法
    * */

    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**");
    }
}
